﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using BizElements.TemplateEngine;

namespace BizElements.Generator
{
    public partial class ComponentDetailsFrm : Form
    {
        public ComponentDetailsFrm()
        {
            InitializeComponent();
        }

        public void SetComponentData(ITemplateInputComponent inputComponent, ComponentType[] subcomponentTypes, IEnumerable<ITemplate> allTemplates, IDictionary<string, IDictionary<string, string>> allComponentVariables)
        {
            this.uiComponentDetails.SetComponentData(inputComponent, subcomponentTypes, allTemplates, allComponentVariables);
        }

        public event EventHandler<EventArgs<IEnumerable<Triple<string, string, string>>>> VariablesChanged;

        private void uiOk_Click(object sender, EventArgs e)
        {
            if (this.VariablesChanged != null)
            {
                List<Triple<string, string, string>> newValues = this.uiComponentDetails.ParseVariables();
                VariablesChanged(this, new EventArgs<IEnumerable<Triple<string, string, string>>>(newValues));
            }

            Close();
        }

        private void uiCancel_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
